/**
 * @format
 */

// import {AppRegistry} from 'react-native';
// import App from './App';
// import {name as appName} from './app.json';
// AppRegistry.registerComponent(appName, () => App);
import {View, Button, StyleSheet} from 'react-native';
import React from 'react';
import Home from './views/Home';
import My from './views/My';
import {Navigation} from 'react-native-navigation';
import Login from './views/Login';
import Product from './views/Product';
import ProductDetail from './views/Product/ProductDetail';
import SearchProduct from './views/Product/SearchProduct';
Home.options = {
  topBar: {
    visible: true, // false,不显示
    title: {
      text: '首页',
      color: 'black',
      alignment: 'center',
    },
    // height: 30,

    // hideOnScroll: true,
    // background: {
    //   color: 'red',
    // },
  },
  bottomTab: {
    text: '首页',
    // badge: 10,//显示为红色的小数字
    icon: require('./assets/iconblue/home.png'),
    selectedIcon: require('./assets/iconpink/home.png'),
  },
};
Product.options = {
  topBar: {
    title: {
      text: '产品',
      color: 'black',
      alignment: 'center',
    },
    rightButtons: [
      {
        // icon: require('./assets/search.png'),
        // text: '搜一下', //有icon时，优先显示icon
        id: 'searchBtn',
        component: {
          name: 'SearchProduct',
        },
      },
    ],
    rightButtonColor: 'gray',
  },
  bottomTab: {
    text: '产品',
    icon: require('./assets/iconblue/product.png'),
    selectedIcon: require('./assets/iconpink/product.png'),
  },
};
My.options = {
  topBar: {
    title: {
      text: '我的',
      alignment: 'center',
    },
    textAlign: 'center',
  },
  bottomTab: {
    text: '我的',
    icon: require('./assets/iconblue/my.png'),
    selectedIcon: require('./assets/iconpink/my.png'),
  },
};
SearchProduct.options = {
  topBar: {
    visible: false,
  },
  // modal: {
  //   swipeToDismiss: true,
  // },
};
// // 先要注册组件；
// ProductDetail.options = {
//   // statusBar: {visible: false}, //隐藏顶部的statusBar
//   topBar: {
//     // visible: false,
//     title: {
//       text: '商品详细',
//       alignment: 'fill',
//       fontSize: 22,
//     },
//   },
// };
Navigation.registerComponent('Login', () => Login);
Navigation.registerComponent('Home', () => Home);
Navigation.registerComponent('My', () => My);
Navigation.registerComponent('Product', () => Product);
Navigation.registerComponent('PrtDetail', () => ProductDetail);
Navigation.registerComponent('SearchProduct', () => SearchProduct);

// 登录根的路由设置
const loginRoot = {
  root: {
    component: {
      name: 'Login',
    },
  },
};

// 默认的导航页版本的配置
Navigation.setDefaultOptions({
  statusBar: {
    backgroundColor: '#4d089a',
    visible: false, //隐藏所有页面的顶部的手机状态栏
  },
  topBar: {
    title: {
      color: 'white',
    },
    backButton: {
      color: 'white',
    },
    background: {
      color: '#e6e6e6',
    },
  },
  bottomTab: {
    fontSize: 14,
    selectedFontSize: 14,
  },
});
// 监听组件事件
Navigation.events().registerAppLaunchedListener(async () => {
  Navigation.setRoot(loginRoot);
});
